package org.xiaom.butler.test;

import java.lang.reflect.ParameterizedType;

import org.xiaom.butler.dao.HotelDao;

public class BaseSub extends Base<HotelDao> {
	public static void main(String[] args) {
		BaseSub b = new BaseSub();
		b.printClazz();
	}
}

abstract class Base<T> {
	private Class<T> persistentClass;

	@SuppressWarnings("unchecked")
	public Base() {
		// 获取持久化对象的类型
		this.persistentClass = (Class<T>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
	}

	public Class<T> getPersistentClass() {
		return persistentClass;
	}

	public void printClazz() {
		System.out.println(persistentClass.getName());
	}
}
